define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'broker/newhouse/index' + location.search,
                    add_url: 'broker/newhouse/add',
                    edit_url: 'broker/newhouse/edit',
                    del_url: 'broker/newhouse/del',
                    multi_url: 'broker/newhouse/multi',
                    import_url: 'broker/newhouse/import',
                    table: 'new_house',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'date_of_visit', title: __('Date_of_visit'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        {field: 'sex_data', title: __('Sex_data'), searchList: {"1":__('Sex_data 1'),"2":__('Sex_data 2')}, formatter: Table.api.formatter.normal},
                        {field: 'contact', title: __('Contact'), operate: 'LIKE'},
                        {field: 'visiting_form_data', title: __('Visiting_form_data'), searchList: {"1":__('Visiting_form_data 1'),"2":__('Visiting_form_data 2'),"3":__('Visiting_form_data 3')}, formatter: Table.api.formatter.normal},
                        {field: 'visiting_form_num', title: __('Visiting_form_num'), operate: 'LIKE'},
                        {field: 'buy_hose_data', title: __('Buy_hose_data'), searchList: {"1":__('Buy_hose_data 1'),"2":__('Buy_hose_data 2'),"3":__('Buy_hose_data 3'),"4":__('Buy_hose_data 4'),"5":__('Buy_hose_data 5'),"6":__('Buy_hose_data 6'),"7":__('Buy_hose_data 7'),"8":__('Buy_hose_data 8')}, formatter: Table.api.formatter.normal},
                        {field: 'house_area', title: __('House_area'), operate: 'LIKE'},
                        {field: 'intentional_building', title: __('Intentional_building'), operate: 'LIKE'},
                        {field: 'intentional_floor', title: __('Intentional_floor'), operate: 'LIKE'},
                        {field: 'dongxihu', title: __('Dongxihu'), operate: 'LIKE'},
                        {field: 'donghu_data', title: __('Donghu_data'), searchList: {"1":__('Donghu_data 1'),"2":__('Donghu_data 2'),"3":__('Donghu_data 3')}, formatter: Table.api.formatter.normal},
                        {field: 'xihu_data', title: __('Xihu_data'), searchList: {"1":__('Xihu_data 1'),"2":__('Xihu_data 2'),"3":__('Xihu_data 3')}, formatter: Table.api.formatter.normal},
                        {field: 'intentional_house_type_data', title: __('Intentional_house_type_data'), searchList: {"1":__('Intentional_house_type_data 1'),"2":__('Intentional_house_type_data 2'),"3":__('Intentional_house_type_data 3')}, formatter: Table.api.formatter.normal},
                        {field: 'satisfaction_level_data', title: __('Satisfaction_level_data'), searchList: {"1":__('Satisfaction_level_data 1'),"2":__('Satisfaction_level_data 2'),"3":__('Satisfaction_level_data 3')}, formatter: Table.api.formatter.normal},
                        {field: 'garage_num_data', title: __('Garage_num_data'), searchList: {"1":__('Garage_num_data 1'),"2":__('Garage_num_data 2')}, formatter: Table.api.formatter.normal},
                        {field: 'price_willingness', title: __('Price_willingness'), operate: 'LIKE'},
                        {field: 'purchase_cycle_data', title: __('Purchase_cycle_data'), searchList: {"1":__('Purchase_cycle_data 1'),"2":__('Purchase_cycle_data 2'),"3":__('Purchase_cycle_data 3'),"4":__('Purchase_cycle_data 4')}, formatter: Table.api.formatter.normal},
                        {field: 'pay_method_data', title: __('Pay_method_data'), searchList: {"1":__('Pay_method_data 1'),"2":__('Pay_method_data 2'),"3":__('Pay_method_data 3')}, formatter: Table.api.formatter.normal},
                        {field: 'number_of_properties', title: __('Number_of_properties'), searchList: {"1":__('Number_of_properties 1'),"2":__('Number_of_properties 2')}, formatter: Table.api.formatter.normal},
                        {field: 'know_the_way_data', title: __('Know_the_way_data'), searchList: {"1":__('Know_the_way_data 1'),"2":__('Know_the_way_data 2'),"3":__('Know_the_way_data 3'),"4":__('Know_the_way_data 4'),"5":__('Know_the_way_data 5'),"6":__('Know_the_way_data 6'),"7":__('Know_the_way_data 7'),"8":__('Know_the_way_data 8'),"9":__('Know_the_way_data 9'),"10":__('Know_the_way_data 10'),"11":__('Know_the_way_data 11')}, formatter: Table.api.formatter.normal},
                        {field: 'make_num', title: __('Make_num')},
                        {field: 'is_transaction', title: __('Is_transaction'), operate: 'LIKE'},
                        {field: 'sales_representative', title: __('Sales_representative'), operate: 'LIKE'},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
